﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace btnet.pages
{
    public partial class categories : CommonPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Bug_Util.do_not_cache(Response);

            security = new Security();
            security.check_security(HttpContext.Current, Security.MUST_BE_ADMIN);

            titl.Text = Bug_Util.get_setting("AppTitle", "BugTracker.NET") + " - "
                + "categories";

            ds = DbUtil.get_dataset(
                        @"select
		        ct_id [id],
		        ct_name [category],
		        ct_sort_seq [sort seq],
		        case when ct_default = 1 then 'Y' else 'N' end [default],
		        ct_id [hidden]
		        from categories order by ct_name");

        }

        /// <summary>
        /// 
        /// </summary>
        protected void displaylist()
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                SortableHtmlTable.create_from_dataset(
                    Response, ds, "edit_category.aspx?id=", "delete_category.aspx?id=");

            }
            else
            {
                Response.Write("No categories in the database.");
            }
        }
    }
}
